home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 90 / CDMM_90_1.ISO / Cycling Manager 2 / CyclingManager2Demo.exe / Disk1 / data1.cab / Game / DataCM2 / scripts / elements / windows.cnh < prev   
Encoding:
Text File  |  2002-05-10  |  24.5 KB  |  927 lines

  1. // windows.cnh
  2.  
  3. // -------------------------------------------------------------
  4. // Constructors
  5. // -------------------------------------------------------------
  6. func Gui_Component NewWindow(i32x _iWidth,i32x _iHeight);
  7. func Gui_Component NewArea(i32x _iWidth,i32x _iHeight);
  8.  
  9. func void Window_AddColumnTitle(Gui_Component _poComponent,Gui_Component _poRef);
  10. func void Window_AddRowTitle(Gui_Component _poComponent,Gui_Component _poRef, i32x _iBackColor);
  11. func void Window_DeleteRowTitle();
  12. //
  13. // Window
  14. // -----------------------------------------------------------------------------------------------------------------
  15. message WindowMount(Gui_Component _poObject);
  16. message WindowSize(i32x _iWidth,i32x _iHeight);
  17. message WindowUpdate();
  18. message WindowAddColumnTitle(Gui_Component _poComponent,Gui_Component _poRef);
  19. message WindowAddRowTitle(Gui_Component _poComponent,Gui_Component _poRef, i32x _iBackColor);
  20. message AreaContentUpdate(i32x _iWidth,i32x _iHeight);
  21. message HScroll(f32x _fValue);
  22. message VScroll(f32x _fValue);
  23. message Resize(Gui_Component _poObject);
  24. //message Update(Gui_Component _gcSender);
  25. message TitleUpdatePosX();
  26. message TitleUpdatePosY();
  27. message SetBackColor(i32x _iColor); // forms
  28. // -------------------------------------------------------------
  29. // -------------------------------------------------------------
  30.  
  31. // Window Data class
  32. class Gui_dtWindow
  33. {
  34.     var i32x iTopMargin;
  35.     var i32x iLeftMargin;
  36.     var i32x iWidth;
  37.     var i32x iHeight;
  38.     var i32x iAreaWidth;
  39.     var i32x iAreaHeight;
  40.     var Gui_Component gcArea; 
  41.     var Gui_Component gcBack;
  42.     var Gui_Component gcBorder;
  43.     var Gui_Component gcSliderH; // Horizontal slider
  44.     var Gui_Component gcSliderV; // Vertical slider
  45.     var Gui_Component gcTitleColumn; 
  46.     var Gui_Component gcTitleRow; 
  47. };
  48. class Gui_dtArea
  49. {
  50.     var i32x iWidth;
  51.     var i32x iHeight;
  52.     var Gui_Component gcChild; 
  53. };
  54. class Gui_dtTitle
  55. {
  56.     var i32x bMouseDown;
  57.     var Gui_Component gcTitle; 
  58.     var Gui_Component gcRef;
  59.     var Gui_Component gcBackground;
  60.     var i32x iBackColor;
  61. };
  62. class Gui_dtTitleList
  63. {
  64.     var Gui_Component gcBackground; 
  65.     var Gui_Component gcLineSeparator;
  66. };
  67.  
  68. // Forward declaration
  69. func void Window_Mount(Gui_Component _poObject);
  70. func void Area_Mount(Gui_Component _poObject);
  71. func void Window_Size(i32x _iWidth,i32x _iHeight);
  72. func void Area_Size(i32x _iWidth,i32x _iHeight);
  73. func void Window_AreaUpdate(i32x _iWidth,i32x _iHeight);
  74. func void Area_Update();
  75. func void Window_SliderChange(Gui_Component _pslider,f32x _fValue);
  76. func void Area_HScroll(f32x _fValue);
  77. func void Area_VScroll(f32x _fValue);
  78. func void Window_MoveX();
  79. func void Window_MoveY();
  80.  
  81. func void TitleList_UpdatePosX();
  82. func void TitleList_UpdatePosY();
  83. func i32x TitleColumn_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
  84. func i32x TitleColumn_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  85. func i32x TitleColumn_OnMouseLeave(i32x _iX,i32x _iY);
  86. func i32x TitleRow_OnGainFocus();
  87. func i32x TitleRow_OnLoseFocus();
  88.  
  89. // Window
  90. interface Gui_iWindow
  91. {
  92.     // System message
  93.     // ...
  94.     // User message
  95.     Window_Mount        WindowMount;
  96.     Window_Size            WindowSize;
  97.     Window_AreaUpdate    AreaContentUpdate;
  98.     Window_AddColumnTitle WindowAddColumnTitle;
  99.     Window_AddRowTitle    WindowAddRowTitle;
  100.     Window_MoveX        TitleUpdatePosX;
  101.     Window_MoveY        TitleUpdatePosY;
  102.     // Slider message response
  103.     Window_SliderChange    SldChange;
  104. }
  105. interface Gui_iArea
  106. {
  107.     // System message
  108.     // ...
  109.     // User message
  110.     Area_Mount            WindowMount;
  111.     Area_Size            WindowSize;
  112.     Area_Update            WindowUpdate;
  113.     // Scroll message
  114.     Area_HScroll        HScroll;
  115.     Area_VScroll        VScroll;
  116. }
  117. interface Gui_iTitleList
  118. {
  119.     TitleList_UpdatePosX    TitleUpdatePosX;
  120.     TitleList_UpdatePosY    TitleUpdatePosY;
  121. }
  122. interface Gui_iTitleColumn
  123. {
  124.     TitleColumn_OnMouseLeave    MouseLeave;
  125.     TitleColumn_OnMouseDown        MouseDown;
  126.     TitleColumn_OnMouseUp        MouseUp;
  127. }
  128.  
  129. interface Gui_iTitleRow
  130. {
  131.     TitleRow_OnGainFocus    GainFocus;
  132.     TitleRow_OnLoseFocus    LoseFocus;
  133. }
  134.  
  135. func i32x TitleColumn_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
  136. {
  137.     var Gui_Component pthis,ptitle;
  138.     var Gui_dtTitle pdtTitle;
  139.  
  140.     // Retrieve title list pointer
  141.     pthis = GetThis();
  142.  
  143.     // Retrieve data pointer
  144.     pdtTitle = GetData(pthis);
  145.  
  146.     if(_iButton == e_Gui_Mouse_Left_Button)
  147.         pdtTitle.bMouseDown = true;
  148. }
  149. func i32x TitleColumn_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton)
  150. {
  151.     var Gui_Component pthis,ptitle;
  152.     var Gui_dtTitle pdtTitle;
  153.  
  154.     // Retrieve title list pointer
  155.     pthis = GetThis();
  156.  
  157.     // Retrieve data pointer
  158.     pdtTitle = GetData(pthis);
  159.  
  160.     if((_iButton == e_Gui_Mouse_Left_Button)&&(pdtTitle.bMouseDown))
  161.     {
  162.         pdtTitle.bMouseDown = false;
  163.         // Send mouse click to ref component
  164.         pdtTitle.gcRef<<Click(pdtTitle.gcTitle);
  165.     }
  166. }
  167.  
  168. func i32x TitleColumn_OnMouseLeave(i32x _iX,i32x _iY)
  169. {
  170.     var Gui_Component pthis,ptitle;
  171.     var Gui_dtTitle pdtTitle;
  172.  
  173.     // Retrieve title list pointer
  174.     pthis = GetThis();
  175.  
  176.     // Retrieve data pointer
  177.     pdtTitle = GetData(pthis);
  178.  
  179.     pdtTitle.bMouseDown = false;
  180. }
  181.  
  182. func i32x TitleRow_OnGainFocus()
  183. {
  184.     var Gui_Component pthis, ptitle, pform;
  185.     var Gui_dtTitle pdtTitle;
  186.  
  187.     // Retrieve title list pointer
  188.     pthis = GetThis();
  189.  
  190.     // Retrieve data pointer
  191.     pdtTitle = GetData(pthis);
  192.  
  193.     SetColor(pdtTitle.gcBackground, cTableSelectColor);
  194.     
  195.     pform = GetParent(pdtTitle.gcRef);
  196.     pform<<SetBackColor(cTableSelectColor);
  197.  
  198.     return 1;
  199. }
  200. func i32x TitleRow_OnLoseFocus()
  201. {
  202.     var Gui_Component pthis, ptitle, pform;
  203.     var Gui_dtTitle pdtTitle;
  204.  
  205.     // Retrieve title list pointer
  206.     pthis = GetThis();
  207.  
  208.     // Retrieve data pointer
  209.     pdtTitle = GetData(pthis);
  210.  
  211.     SetColor(pdtTitle.gcBackground, pdtTitle.iBackColor);
  212.  
  213.     pform = GetParent(pdtTitle.gcRef);
  214.     pform<<SetBackColor(pdtTitle.iBackColor);
  215. }
  216.  
  217. func i32x TitleRow_OnMouseLeave(i32x _iX,i32x _iY)
  218. {
  219.     //println("onmouseleave");
  220. /*
  221.     var Gui_Component pthis,ptitle;
  222.     var Gui_dtTitle pdtTitle;
  223.  
  224.     // Retrieve title list pointer
  225.     pthis = GetThis();
  226.  
  227.     // Retrieve data pointer
  228.     pdtTitle = GetData(pthis);
  229.  
  230.     pdtTitle.bMouseDown = false;
  231. */
  232. }
  233.  
  234.  
  235.  
  236.  
  237. func Gui_Component NewWindow(i32x _iWidth,i32x _iHeight)
  238. {
  239.     var Gui_Component pwindow, pborder, pWindowBack, pWindowBorder, pColumnTitleBack, pLineSeparator;
  240.     var Gui_dtWindow pdtWindow;
  241.     var Gui_dtTitleList pdtTitleList;
  242.     
  243.     // Create column object
  244.     pwindow = NewObject(Gui_iWindow);
  245.     pdtWindow = new Gui_dtWindow;
  246.     SetData(pwindow,pdtWindow);
  247.     SetComponentNumber(pwindow,4);
  248.  
  249.     // Create Area
  250.     pdtWindow.gcArea = NewArea(_iWidth,_iHeight);
  251.     Transparent(pdtWindow.gcArea);
  252.  
  253.     // create window background
  254.     pWindowBack = NewBoxFilled(smBlueFrame, _iWidth, _iHeight);
  255.     pWindowBack<<Disable();
  256.     MountComponent(pwindow, pWindowBack);
  257.     pdtWindow.gcBack = pWindowBack;
  258.  
  259.     // create window border
  260.     pWindowBorder = NewBox(smWhiteBorder, _iWidth, _iHeight);
  261.     pWindowBorder<<Disable();
  262.     MountComponent(pwindow, pWindowBorder);
  263.     pdtWindow.gcBorder = pWindowBorder;
  264.  
  265.     // create sliders
  266.     pdtWindow.gcSliderV = NewSliderCompositeV(smSlider_V,_iHeight,smUpButton,smDownButton,smWhite);
  267.     pdtWindow.gcSliderH = NewSliderCompositeH(smSlider_H,_iWidth,smLeftButton,smRightButton,smWhite);
  268.     
  269.     // create title for columns
  270.     pdtWindow.gcTitleColumn = NewObject(Gui_iTitleList);
  271.     pdtTitleList = new Gui_dtTitleList;
  272.     SetData(pdtWindow.gcTitleColumn, pdtTitleList);
  273.     // create column title back
  274.     pColumnTitleBack = NewBoxFilled(smWhiteFrame, 10, 10);
  275.     pColumnTitleBack<<BoxSetColor(cTableColumnTitleColor);
  276.     pColumnTitleBack<<Hide(); // hide until we have titles to display
  277.     pColumnTitleBack<<Disable();
  278.     pdtTitleList.gcBackground = pColumnTitleBack;
  279.     MountComponent(pdtWindow.gcTitleColumn, pColumnTitleBack);
  280.     pdtTitleList.gcLineSeparator = 0;
  281.     // create title row line separator
  282.     pLineSeparator = NewBitmap(smWhite, 0);
  283.     SetShadingMode(GetSprite(pLineSeparator), DLC_GouraudMode_ModulateDiffuse, DLC_GouraudMode_ModulateDiffuse);
  284.     SetBlendingMode(GetSprite(pLineSeparator), DLC_Blend_AlphaBlend);
  285.     SetAlign(pLineSeparator, e_GUI_HAlign_Zoom, e_GUI_VAlign_Bottom);
  286.     SetScale(pLineSeparator, iTableLineWidth);
  287.     SetColor(pLineSeparator, cTableLineColor);
  288.     pLineSeparator<<Hide(); // hide until we have titles to display
  289.     pLineSeparator<<Disable();
  290.     pdtTitleList.gcLineSeparator = pLineSeparator;
  291.     MountComponent(pdtWindow.gcTitleColumn, pLineSeparator);
  292.  
  293.     // create titles for row
  294.     pdtWindow.gcTitleRow = NewObject(Gui_iTitleList);
  295.     pdtTitleList = new Gui_dtTitleList;
  296.     SetData(pdtWindow.gcTitleRow, pdtTitleList);
  297.     // create title row line separator
  298.     pLineSeparator = NewBitmap(smWhite, 0);
  299.     SetShadingMode(GetSprite(pLineSeparator), DLC_GouraudMode_ModulateDiffuse, DLC_GouraudMode_ModulateDiffuse);
  300.     SetBlendingMode(GetSprite(pLineSeparator), DLC_Blend_AlphaBlend);
  301.     SetAlign(pLineSeparator, e_GUI_HAlign_Right, e_GUI_VAlign_Zoom);
  302.     SetScale(pLineSeparator, iTableLineWidth);
  303.     SetColor(pLineSeparator, cTableLineColor);
  304.     pLineSeparator<<Hide(); // hide until we have titles to display
  305.     pLineSeparator<<Disable();
  306.     pdtTitleList.gcLineSeparator = pLineSeparator;
  307.     MountComponent(pdtWindow.gcTitleRow, pLineSeparator);
  308.  
  309.     // mount titles
  310.     MountComponent(pwindow, pdtWindow.gcTitleColumn);
  311.     MountComponent(pwindow, pdtWindow.gcTitleRow);
  312.     
  313.     //clip titles
  314.     Clip(pdtWindow.gcTitleColumn);
  315.     Clip(pdtWindow.gcTitleRow);
  316.     // pdtWindow.gcTitleColumn<<Disable();
  317.     // pdtWindow.gcTitleRow<<Disable();
  318.  
  319.     // Fill data
  320.     pdtWindow.iWidth = _iWidth;
  321.     pdtWindow.iHeight = _iHeight;
  322.     pdtWindow.iTopMargin = 0;
  323.     pdtWindow.iLeftMargin = 0;
  324.  
  325.     // Mount Component into window
  326.     MountComponent(pwindow,pdtWindow.gcArea);
  327.     MountComponent(pwindow,pdtWindow.gcSliderH);
  328.     MountComponent(pwindow,pdtWindow.gcSliderV);
  329.  
  330.     // Stretch window to area
  331.     StretchTo(pwindow,_iWidth,_iHeight);
  332.     Clip(pwindow);
  333.     Transparent(pwindow);
  334.  
  335.     // Move slider
  336.     MoveTo(pdtWindow.gcSliderV,_iWidth - SizeX(pdtWindow.gcSliderV),0);
  337.     MoveTo(pdtWindow.gcSliderH,0,_iHeight - SizeY(pdtWindow.gcSliderH));
  338.  
  339.     // Hide slider
  340.     pdtWindow.gcSliderH<<Hide();
  341.     pdtWindow.gcSliderV<<Hide();
  342.  
  343.     return pwindow;
  344. }
  345.  
  346. func void Window_AddColumnTitle(Gui_Component _poComponent, Gui_Component _poRef)
  347. {
  348.     var Gui_Component pwindow,ptitle;
  349.     var Gui_dtWindow pdtWindow;
  350.     var Gui_dtTitle pdtTitle;
  351.     var Gui_dtTitleList pdtTitleList;
  352.     var i32x w,h,iPosX;
  353.     var i32x iAreaWidth,iAreaHeight;
  354.  
  355.     // Retrieve area pointer
  356.     pwindow = GetThis();
  357.  
  358.     // Retrieve data pointer
  359.     pdtWindow = GetData(pwindow);
  360.  
  361.     ptitle = NewObject(Gui_iTitleColumn);
  362.     pdtTitle = new Gui_dtTitle;
  363.     SetData(ptitle, pdtTitle);
  364.     Clip(ptitle);
  365.  
  366.     //Reference component into title
  367.     pdtTitle.gcTitle = _poComponent;
  368.     pdtTitle.gcRef = _poRef;
  369.     // Mount component into title
  370.     MountComponent(ptitle,_poComponent);
  371.     //MoveTo(_poComponent,RelPosX(_poComponent),0);
  372.  
  373.     // Get component size
  374.     w = SizeX(_poComponent);
  375.     h = SizeY(_poComponent);
  376.     h = h + iListBoxFieldPadding*2; // add padding
  377.  
  378.     // Mount title object into list title
  379.     MountComponent(pdtWindow.gcTitleColumn, ptitle);
  380.     
  381.     // Move title to correct pos
  382.     iPosX = AbsPosX(pdtTitle.gcRef) - AbsPosX(pdtWindow.gcTitleColumn);
  383.     MoveTo(ptitle,iPosX, 0);
  384.     StretchTo(ptitle,w,h);
  385.  
  386.     // Update area pos
  387.     if(h>pdtWindow.iTopMargin)
  388.     {
  389.         pdtWindow.iAreaHeight = pdtWindow.iAreaHeight - (h-pdtWindow.iTopMargin);
  390.         pdtWindow.iTopMargin=h;
  391.     }
  392.     pdtWindow.gcArea<<WindowSize(pdtWindow.iAreaWidth,pdtWindow.iAreaHeight);
  393.     MoveTo(pdtWindow.gcArea,pdtWindow.iLeftMargin,pdtWindow.iTopMargin);
  394.  
  395.     // Update title list size and pos
  396.     if(h<SizeY(pdtWindow.gcTitleColumn))
  397.         h = SizeY(pdtWindow.gcTitleColumn);
  398.  
  399.     pdtTitleList = GetData(pdtWindow.gcTitleColumn);
  400.     
  401.     //StretchTo(pdtTitleList.gcBackground, pdtWindow.iAreaWidth + pdtWindow.iLeftMargin, h);
  402.     StretchTo(pdtWindow.gcTitleColumn, pdtWindow.iWidth - pdtWindow.iLeftMargin, h);
  403. //    StretchTo(pdtTitleList.gcBackground, pdtWindow.iWidth - pdtWindow.iLeftMargin, h);
  404.     MoveTo(pdtWindow.gcTitleColumn, pdtWindow.iLeftMargin, 0);
  405.     pdtTitleList.gcBackground<<Show(); // show background
  406.  
  407.     // Move Vertical slider to manage top margin
  408.     MoveTo(pdtWindow.gcSliderV,RelPosX(pdtWindow.gcSliderV),pdtWindow.iTopMargin);
  409.     // Update its size
  410.     pdtWindow.gcSliderV<<SldSize(pdtWindow.iAreaHeight);
  411.  
  412.     // show line separator
  413.     pdtTitleList = GetData(pdtWindow.gcTitleColumn);
  414.     pdtTitleList.gcLineSeparator<<Show();
  415. }
  416.  
  417. func void Window_AddRowTitle(Gui_Component _poComponent,Gui_Component _poRef, i32x _iBackColor)
  418. {
  419.     var Gui_Component pwindow,ptitle;
  420.     var Gui_dtWindow pdtWindow;
  421.     var Gui_dtTitle pdtTitle;
  422.     var Gui_dtTitleList pdtTitleList;
  423.  
  424.     var i32x w,h,iPosY;
  425.     var i32x iAreaWidth,iAreaHeight;
  426.  
  427.     // Retrieve area pointer
  428.     pwindow = GetThis();
  429.  
  430.     // Retrieve data pointer
  431.     pdtWindow = GetData(pwindow);
  432.  
  433.     ptitle = NewObject(Gui_iTitleRow);
  434.     pdtTitle = new Gui_dtTitle;
  435.     SetData(ptitle, pdtTitle);
  436.  
  437.     // init background
  438.     pdtTitle.gcBackground = NewBitmap(smWhite, 0);
  439.     SetShadingMode(GetSprite(pdtTitle.gcBackground), DLC_GouraudMode_ModulateDiffuse, DLC_GouraudMode_ModulateDiffuse);
  440.     SetBlendingMode(GetSprite(pdtTitle.gcBackground), DLC_Blend_AlphaBlend);
  441.     SetAlign(pdtTitle.gcBackground, e_GUI_HAlign_Zoom, e_GUI_VAlign_Zoom);
  442.     pdtTitle.gcBackground<<Disable();
  443.     Clip(pdtTitle.gcBackground);
  444.     MountComponent(ptitle, pdtTitle.gcBackground);
  445.  
  446.     //Reference component into title
  447.     pdtTitle.gcTitle = _poComponent;
  448.     pdtTitle.gcRef = _poRef;
  449.     _poComponent<<Disable();
  450.     // Mount component into title
  451.     MountComponent(ptitle,_poComponent);
  452.  
  453.     // Get component size
  454.     w = SizeX(_poComponent);
  455.     h = SizeY(_poComponent);
  456.  
  457.     // Mount title object into list title
  458.     MountComponent(pdtWindow.gcTitleRow,ptitle);
  459.  
  460.     // Move title to correct pos
  461.     iPosY = AbsPosY(pdtTitle.gcRef) - AbsPosY(pdtWindow.gcTitleColumn);
  462.     MoveTo(ptitle,0,iPosY);
  463.     StretchTo(ptitle,w,h);
  464.  
  465.     // update background size and color
  466.     StretchTo(pdtTitle.gcBackground, w, h);
  467.     pdtTitle.iBackColor = _iBackColor;
  468.     SetColor(pdtTitle.gcBackground, pdtTitle.iBackColor);
  469.  
  470.     // Update area pos
  471.     if(w>pdtWindow.iLeftMargin)
  472.     {
  473.         pdtWindow.iAreaWidth = pdtWindow.iAreaWidth - (w-pdtWindow.iLeftMargin);
  474.         pdtWindow.iLeftMargin=w;
  475.     }
  476.     pdtWindow.gcArea<<WindowSize(pdtWindow.iAreaWidth,pdtWindow.iAreaHeight);
  477.     MoveTo(pdtWindow.gcArea,pdtWindow.iLeftMargin,pdtWindow.iTopMargin);
  478.  
  479.  
  480.     // print("TitleSize:"+itoa(x)+":"+itoa(y)+":"+itoa(w)+":"+itoa(h)+"\n");
  481.     // Update title list size and pos
  482.     if(w<SizeX(pdtWindow.gcTitleRow))
  483.     {
  484.         w  = SizeX(pdtWindow.gcTitleRow);
  485.     }
  486.     MoveTo(pdtWindow.gcTitleRow,0,pdtWindow.iTopMargin);
  487.     // Always max size
  488.     StretchTo(pdtWindow.gcTitleRow,w,pdtWindow.iAreaHeight);
  489.  
  490.     // Move Vertical slider to manage top margin
  491.     MoveTo(pdtWindow.gcSliderH,pdtWindow.iLeftMargin,RelPosY(pdtWindow.gcSliderH));
  492.     // Update its size
  493.     pdtWindow.gcSliderH<<SldSize(pdtWindow.iAreaWidth);
  494.  
  495.     // show line separator
  496.     pdtTitleList = GetData(pdtWindow.gcTitleRow);
  497.     pdtTitleList.gcLineSeparator<<Show();
  498. }
  499.  
  500.  
  501. func void TitleList_UpdatePosX()
  502. {
  503.     var Gui_Component pthis,ptitle;
  504.     var i32x iNumComponents,i;
  505.     var i32x iPosX;
  506.     var Gui_dtTitleList pdtTitleList;
  507.     var Gui_dtTitle pdtTitle;
  508.  
  509.     // Retrieve title list pointer
  510.     pthis = GetThis();
  511.  
  512.     pdtTitleList = GetData(pthis);
  513.  
  514.     iNumComponents = GetComponentNumber(pthis);
  515.     i=0;
  516.     while(i<iNumComponents)
  517.     {
  518.         ptitle=GetComponent(pthis,i);
  519.         if((ptitle)&&(ptitle!=pdtTitleList.gcBackground)&&(ptitle!=pdtTitleList.gcLineSeparator))
  520.         {
  521.             pdtTitle = GetData(ptitle);
  522.             // Move title to correct pos
  523.             iPosX = AbsPosX(pdtTitle.gcRef) - AbsPosX(pthis);
  524.             MoveTo(ptitle,iPosX,0);
  525.         }
  526.         i=i+1;
  527.     }
  528. }
  529.  
  530. func void TitleList_UpdatePosY()
  531. {
  532.     var Gui_Component pthis,ptitle;
  533.     var i32x iNumComponents,i,iPosY;
  534.     var Gui_dtTitleList pdtTitleList;
  535.     var Gui_dtTitle pdtTitle;
  536.  
  537.     // Retrieve title list pointer
  538.     pthis = GetThis();
  539.     pdtTitleList = GetData(pthis);
  540.  
  541.     iNumComponents = GetComponentNumber(pthis);
  542.     i=0;
  543.     while(i<iNumComponents)
  544.     {
  545.         ptitle=GetComponent(pthis,i);
  546.         if((ptitle)&&(ptitle!=pdtTitleList.gcBackground)&&(ptitle!=pdtTitleList.gcLineSeparator))
  547.         {
  548.             pdtTitle = GetData(ptitle);
  549.             // Move title to correct pos
  550.             iPosY = AbsPosY(pdtTitle.gcRef) - AbsPosY(pthis);
  551.             MoveTo(ptitle,0,iPosY);
  552.             // Move component
  553.             //Move(ptitle,0,_iValue);
  554.         }
  555.         i=i+1;
  556.     }
  557. }
  558.  
  559. func Gui_Component NewArea(i32x _iWidth,i32x _iHeight)
  560. {
  561.     var Gui_Component parea;
  562.     var Gui_dtArea pdtArea;
  563.  
  564.     // Create column object
  565.     parea = NewObject(Gui_iArea);
  566.     pdtArea = new Gui_dtArea;
  567.     SetData(parea,pdtArea);
  568.     SetComponentNumber(parea,1);
  569.  
  570.     // Fill data
  571.     pdtArea.iWidth = _iWidth;
  572.     pdtArea.iHeight = _iHeight;
  573.  
  574.     // Stretch area to wanted size
  575.     StretchTo(parea,_iWidth,_iHeight);
  576.     Clip(parea);
  577.     Transparent(parea);
  578.  
  579.     return parea;
  580. }
  581.  
  582. // Mount an object into area
  583. func void Area_Mount(Gui_Component _poObject)
  584. {
  585.     var Gui_Component parea;
  586.     var Gui_dtArea pdtArea;
  587.  
  588.     // Retrieve area pointer
  589.     parea = GetThis();
  590.  
  591.     // Retrieve data pointer
  592.     pdtArea = GetData(parea);
  593.  
  594.     // Mount object into area
  595.     MountComponent(parea,_poObject);
  596.     pdtArea.gcChild = _poObject;
  597.  
  598.     // Update Window
  599.     Area_Update();
  600. }
  601.  
  602. // Mount an object into window
  603. func void Window_Mount(Gui_Component _poObject)
  604. {
  605.     var Gui_Component pwindow,parea;
  606.     var Gui_dtWindow pdtWindow;
  607.  
  608.     // Retrieve area pointer
  609.     pwindow = GetThis();
  610.  
  611.     // Retrieve data pointer
  612.     pdtWindow = GetData(pwindow);
  613.  
  614.     // Tell area to mount component
  615.     pdtWindow.gcArea<<WindowMount(_poObject);
  616. }
  617.  
  618. func void Window_Size(i32x _iWidth,i32x _iHeight)
  619. {
  620.     var Gui_Component pwindow,parea;
  621.     var Gui_dtWindow pdtWindow;
  622.     var i32x iAreaWidth,iAreaHeight;
  623.  
  624.     // Retrieve area pointer
  625.     pwindow = GetThis();
  626.  
  627.     // Retrieve data pointer
  628.     pdtWindow = GetData(pwindow);
  629.  
  630.     // Update data
  631.     pdtWindow.iWidth = _iWidth;
  632.     pdtWindow.iHeight = _iHeight;
  633.     pdtWindow.iAreaWidth = pdtWindow.iWidth-pdtWindow.iLeftMargin;
  634.     pdtWindow.iAreaHeight = pdtWindow.iWidth-pdtWindow.iTopMargin;
  635.  
  636.     // Update Area
  637.     pdtWindow.gcArea<<WindowSize(pdtWindow.iAreaWidth,pdtWindow.iAreaHeight);
  638.  
  639.     // Stretch Window
  640.     StretchTo(pwindow,_iWidth,_iHeight);
  641. }
  642. func void Area_Size(i32x _iWidth,i32x _iHeight)
  643. {
  644.     var Gui_Component parea;
  645.     var Gui_dtArea pdtArea;
  646.  
  647.     // Retrieve area pointer
  648.     parea = GetThis();
  649.  
  650.     // Retrieve data pointer
  651.     pdtArea = GetData(parea);
  652.  
  653.     // Update data
  654.     pdtArea.iWidth = _iWidth;
  655.     pdtArea.iHeight = _iHeight;
  656.  
  657.     // Stretch Area
  658.     StretchTo(parea,_iWidth,_iHeight);
  659. }
  660. func void Window_MoveX()
  661. {
  662.     var Gui_Component pwindow;
  663.     var Gui_dtWindow pdtWindow;
  664.  
  665.     // Retrieve area pointer
  666.     pwindow = GetThis();
  667.  
  668.     // Retrieve data pointer
  669.     pdtWindow = GetData(pwindow);
  670.  
  671.     pdtWindow.gcTitleColumn<<TitleUpdatePosX();
  672. }
  673. func void Window_MoveY()
  674. {
  675.     var Gui_Component pwindow;
  676.     var Gui_dtWindow pdtWindow;
  677.  
  678.     // Retrieve area pointer
  679.     pwindow = GetThis();
  680.  
  681.     // Retrieve data pointer
  682.     pdtWindow = GetData(pwindow);
  683.  
  684.     pdtWindow.gcTitleRow<<TitleUpdatePosY();
  685. }
  686.  
  687. func void Window_AreaUpdate(i32x _iWidth,i32x _iHeight)
  688. {
  689.     var boolx bHS,bVS;
  690.     var i32x iWidth,iHeight;
  691.     var i32x iBackWidth, iBackHeight;
  692.     var Gui_Component pwindow;
  693.     var Gui_dtWindow pdtWindow;
  694.     var Gui_Component ptitle;
  695.     var Gui_dtTitle pdtTitle;
  696.     var Gui_dtTitleList pdtTitleList;
  697.     var i32x i,iNumRowTitle;
  698.  
  699.     // Retrieve area pointer
  700.     pwindow = GetThis();
  701.  
  702.     // Retrieve data pointer
  703.     pdtWindow = GetData(pwindow);
  704.  
  705.     // Check slider needs
  706.     //Horizontal
  707.     if(pdtWindow.iWidth-pdtWindow.iLeftMargin<_iWidth)
  708.     {
  709.         pdtWindow.gcSliderH<<Show();
  710.         iHeight = pdtWindow.iHeight - SizeY(pdtWindow.gcSliderH) - pdtWindow.iTopMargin;
  711.         iBackHeight = pdtWindow.iHeight - SizeY(pdtWindow.gcSliderH) / 2;
  712.         bHS = true;
  713.     }
  714.     else
  715.     {
  716.         pdtWindow.gcSliderH<<Hide();
  717.         iHeight = pdtWindow.iHeight - pdtWindow.iTopMargin;
  718.         iBackHeight = pdtWindow.iHeight;
  719.         bHS = false;
  720.     }
  721.     // Vertical
  722.     if(iHeight<_iHeight)
  723.     {
  724.         pdtWindow.gcSliderV<<Show();
  725.         iWidth = pdtWindow.iWidth - SizeX(pdtWindow.gcSliderV) - pdtWindow.iLeftMargin;
  726.         iBackWidth = pdtWindow.iWidth - SizeX(pdtWindow.gcSliderV) / 2;
  727.         if(!bHS)
  728.         {
  729.             // Recheck horizontal slider need
  730.             if(iWidth<_iWidth)
  731.             {
  732.                 pdtWindow.gcSliderH<<Show();
  733.                 iHeight = pdtWindow.iHeight - SizeY(pdtWindow.gcSliderH) - pdtWindow.iTopMargin;
  734.                 iBackHeight = pdtWindow.iHeight - SizeY(pdtWindow.gcSliderH) / 2;
  735.                 bHS = true;
  736.             }
  737.         }
  738.         bVS = true;
  739.     }
  740.     else
  741.     {
  742.         pdtWindow.gcSliderV<<Hide();
  743.         iWidth = pdtWindow.iWidth - pdtWindow.iLeftMargin;
  744.         iBackWidth = pdtWindow.iWidth;
  745.         bVS = false;
  746.     }
  747.     // Update Area size
  748.     pdtWindow.iAreaWidth = iWidth;
  749.     pdtWindow.iAreaHeight = iHeight;
  750.     pdtWindow.gcArea<<WindowSize(iWidth,iHeight);
  751.     // update background size
  752.     pdtWindow.gcBack<<BoxResize(iBackWidth, iBackHeight);
  753.     
  754.     pdtWindow.gcBorder<<BoxResize(iBackWidth, iBackHeight);
  755.     
  756.     // update title row
  757.     StretchTo(pdtWindow.gcTitleRow, SizeX(pdtWindow.gcTitleRow), iHeight);
  758.     MoveTo(pdtWindow.gcTitleRow, 0, pdtWindow.iTopMargin);
  759.     // line separator
  760.     pdtTitleList = GetData(pdtWindow.gcTitleRow);
  761.     StretchTo(pdtTitleList.gcLineSeparator, SizeX(pdtWindow.gcTitleRow), iHeight+pdtWindow.iTopMargin);
  762.     MoveTo(pdtTitleList.gcLineSeparator, 0, 0-pdtWindow.iTopMargin);
  763.  
  764.     // update title column
  765.     StretchTo(pdtWindow.gcTitleColumn, iBackWidth - pdtWindow.iLeftMargin, SizeY(pdtWindow.gcTitleColumn));
  766.     // update title column back
  767.     pdtTitleList = GetData(pdtWindow.gcTitleColumn);
  768.     pdtTitleList.gcBackground<<BoxResize(iBackWidth, SizeY(pdtWindow.gcTitleColumn));
  769.     // StretchTo(pdtTitleList.gcBackground, iBackWidth, SizeY(pdtWindow.gcTitleColumn));
  770.     MoveTo(pdtTitleList.gcBackground, 0-pdtWindow.iLeftMargin, 0);
  771.     // line separator
  772.     StretchTo(pdtTitleList.gcLineSeparator, iWidth+pdtWindow.iLeftMargin, SizeY(pdtWindow.gcTitleColumn));
  773.     MoveTo(pdtTitleList.gcLineSeparator, 0-pdtWindow.iLeftMargin, 0);
  774.     
  775.     // Update title pos
  776.     pdtWindow.gcTitleColumn<<TitleUpdatePosX();
  777.     pdtWindow.gcTitleRow<<TitleUpdatePosY();
  778.  
  779.     // Update slider size
  780.     if(bHS)
  781.     {
  782.         pdtWindow.gcSliderV<<SldSize(iHeight);
  783.     }
  784.     if(bVS)
  785.     {
  786.         pdtWindow.gcSliderH<<SldSize(iWidth);
  787.     }
  788.  
  789.     // Check hidden row title
  790.     // Warning Hades check Background of title row !
  791.     iNumRowTitle = GetComponentNumber(pdtWindow.gcTitleRow);
  792.     i=0;
  793.     
  794.  
  795.  
  796.     pdtTitleList = GetData(pdtWindow.gcTitleRow);
  797.     
  798.     while(i<iNumRowTitle)
  799.     {
  800.         ptitle = GetComponent(pdtWindow.gcTitleRow,i);
  801.         
  802.         if((ptitle)&&(ptitle != pdtTitleList.gcLineSeparator))
  803.         {
  804.             pdtTitle = GetData(ptitle);
  805.             if(IsHidden(GetParent(pdtTitle.gcRef)))
  806.             {
  807.                 ptitle<<Hide();
  808.             }
  809.             else
  810.             {
  811.                 ptitle<<Show();
  812.                 // update rowtitle back color
  813.                 if (IsFocused(GetParent(pdtTitle.gcRef))) SetColor(pdtTitle.gcBackground, cTableSelectColor);
  814.                 else SetColor(pdtTitle.gcBackground, pdtTitle.iBackColor);
  815.             }
  816.         }
  817.         i=i+1;
  818.     }
  819. }
  820.  
  821. func void Area_Update()
  822. {
  823.     var i32x iWidth,iHeight;
  824.     var Gui_Component parea,pwindow;
  825.     var Gui_dtArea pdtArea;
  826.  
  827.     // Retrieve area pointer
  828.     parea = GetThis();
  829.  
  830.     // Retrieve data pointer
  831.     pdtArea = GetData(parea);
  832.     if(pdtArea.gcChild)
  833.     {
  834.         iWidth = SizeX(pdtArea.gcChild);
  835.         iHeight = SizeY(pdtArea.gcChild);
  836.     }
  837.     else
  838.     {
  839.         iWidth = 0;
  840.         iHeight = 0;
  841.     }
  842.  
  843.     // Retrieve parent window
  844.     pwindow = GetParent(parea);
  845.  
  846.     // Update windows inner size
  847.     pwindow<<AreaContentUpdate(iWidth,iHeight);
  848. }
  849.  
  850. func void Window_SliderChange(Gui_Component _pslider,f32x _fValue)
  851. {
  852.     var Gui_Component pwindow;
  853.     var Gui_dtWindow pdtWindow;
  854.  
  855.     // Retrieve area pointer
  856.     pwindow = GetThis();
  857.  
  858.     // Retrieve data pointer
  859.     pdtWindow = GetData(pwindow);
  860.  
  861.     // Which slider ?
  862.     if(_pslider == pdtWindow.gcSliderH)
  863.     {
  864.         pdtWindow.gcArea<<HScroll(_fValue);
  865.     }
  866.     if(_pslider == pdtWindow.gcSliderV)
  867.     {
  868.         pdtWindow.gcArea<<VScroll(_fValue);
  869.     }
  870. }
  871.  
  872. func void Area_HScroll(f32x _fValue)
  873. {
  874.     var i32x iDeltaWidth,iPosX;
  875.     var f32x fOffset;
  876.     var Gui_Component parea,pwindow;
  877.     var Gui_dtArea pdtArea;
  878.  
  879.     // Retrieve area pointer
  880.     parea = GetThis();
  881.  
  882.     // Retrieve data pointer
  883.     pdtArea = GetData(parea);
  884.  
  885.     // Move child
  886.     iDeltaWidth = SizeX(pdtArea.gcChild) - pdtArea.iWidth;
  887.     if(iDeltaWidth>0)
  888.     {
  889.         fOffset = -iDeltaWidth;
  890.         fOffset = fOffset*_fValue;
  891.         iPosX = fOffset+0.5;
  892.         MoveTo(pdtArea.gcChild,iPosX,RelPosY(pdtArea.gcChild));
  893.  
  894.         // Retrieve parent window
  895.         pwindow = GetParent(parea);
  896.         pwindow<<TitleUpdatePosX();
  897.     }
  898. }
  899. func void Area_VScroll(f32x _fValue)
  900. {
  901.     var i32x iDeltaHeight,iPosY,iDeltaY;
  902.     var f32x fOffset;
  903.     var Gui_Component parea,pwindow;
  904.     var Gui_dtArea pdtArea;
  905.  
  906.     // Retrieve area pointer
  907.     parea = GetThis();
  908.  
  909.     // Retrieve data pointer
  910.     pdtArea = GetData(parea);
  911.  
  912.     // Move child
  913.     iDeltaHeight = SizeY(pdtArea.gcChild) - pdtArea.iHeight;
  914.     if(iDeltaHeight>0)
  915.     {
  916.         fOffset = -iDeltaHeight;
  917.         fOffset = fOffset*_fValue;
  918.         iPosY = fOffset+0.5;
  919.         MoveTo(pdtArea.gcChild,RelPosX(pdtArea.gcChild),iPosY);
  920.         // Retrieve parent window
  921.         pwindow = GetParent(parea);
  922.  
  923.         pwindow<<TitleUpdatePosY();
  924.     }
  925. }
  926.  
  927.